<template>
	<view class="container">
	    <view class="form-group">
	      <input type="text" :value="username" @input="updateUsername" placeholder="请输入用户名" />
	    </view>
	    <view class="form-group">
	      <input type="password" :value="password" @input="updatePassword" placeholder="请输入密码" />
	    </view>
	    <button @click="onLogin">登录</button>
	  </view>
</template>

<script setup>
import{ ref } from 'vue';

// 定义响应式状态
const username = ref('');
const password = ref('');

// 更新状态的方法
const updateUsername  = (event) => {
  username.value = event.target.value;
};

const updatePassword  = (event) => {
  password.value = event.target.value;
};

// 登录方法
const onLogin = () => {
  if (username.value === '' || password.value === '') {
    uni.showToast({
      title: '请填写完整信息',
      icon: 'none'
    });
    return;
  }

  console.log('尝试登录：', { username: username.value, password: password.value });

  // 假设登录成功后的操作
  uni.reLaunch({
    url: '/pages/index/index'
  });
};




</script>

<style lang="scss">
	
.container {
  padding: 20px;
}

.form-group {
  margin-bottom: 15px;
}
</style>
